boxee.autoChoosePlayer=true;
boxee.renderBrowser=false;
boxee.enableLog(true);
boxee.setCanPause(true);
boxee.setCanSkip(true);
boxee.log('Testing');
boxee.setDefaultCrop(548,250,420,230);
//boxee.setDefaultCrop(820,530,420,130);

var y = 535;
var channel_x = new Array(548,610,680,750,820,890);
var channel_name = new Array("RCTI","TransTV","SCTV","MetroTV","GlobalTV","MivoTV");
var current_channel = 5;

function R(p) { return (p & 0x00ff0000) >> 16; }
function G(p) { return (p & 0x0000ff00) >> 8; }
function B(p) { return (p & 0x000000ff) ; }

boxee.onPause = function()
{
   	boxee.log('user pressed pause');
	widget = boxee.getActiveWidget();
	widget.click(582,238);
}
 
boxee.onPlay = function()
{
   	boxee.log('user pressed play');
	widget = boxee.getActiveWidget();
	widget.click(595,238);
}

boxee.onBack = function()
{
	boxee.log('user pressed back')
	widget = boxee.getActiveWidget();
	//widget.mouseMove(10, 10);
	current_channel = current_channel-1;
	if(current_channel < 0) {
		current_channel = channel_x.length-1;
	}
	boxee.log("current_channel:"+current_channel);
	widget.click(channel_x[current_channel], y);
	alert(channel_name[current_channel]);
	boxee.notifyPlaybackResumed();
}

boxee.onSkip = function()
{
	boxee.log("user pressed skip")
	widget = boxee.getActiveWidget();
	//widget.mouseMove(10, 10);
	current_channel = current_channel+1;
	if(current_channel >= channel_x.length) {
		current_channel = 0;
	}
	boxee.log("current_channel:"+current_channel);
	widget.click(channel_x[current_channel], y);
	alert(channel_name[current_channel]);
	boxee.notifyPlaybackResumed();
}